package com.sasis.webapp.dwr;

import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import com.sasis.model.City;
import com.sasis.service.CityManager;

public class CityRemote {
	private CityManager cityManager; 
	
	public void setCityManager(CityManager cityManager) {
		this.cityManager = cityManager;
	}
	
	public Map getCityList(){
		City city = new City();
		List list = cityManager.getCitys(city);
		HashMap map = new LinkedHashMap(); 
		for (Iterator iter = list.iterator(); iter.hasNext();) {
			City element = (City) iter.next();
			map.put(element.getId(), element.getName());
		}
		 
		return map;
	}
	public boolean saveCity(String code,String name){
		City city = new City();
		city.setCode(code);
		city.setName(name);
		cityManager.saveCity(city);
		 
		return true;
	}
}
